let toasts = document.querySelector("#toasts");
let btn = document.querySelector('button')
let status = ['success', 'info', 'warn', 'error']
let info = ['成功','提示','警告','错误']
btn.addEventListener('click', (e) => {
    let div = document.createElement('div')
    let info = getRandomInfo();
    div.innerHTML = info[1];
	div.classList.add("toast");
    
    div.classList.add(info[0]);
    
    toasts.appendChild(div)

    setTimeout(() => {
        toasts.removeChild(div)
    }, 2000);
})

function getRandomInfo() {
    let num = Math.floor(Math.random() * info.length);
    return [status[num],info[num]]
}